﻿/******************************************************************************
 * GLocalTypes.cs
 * 
 * This module implements the DataContract types needed to query Google Local
 * 
 * Date:   1/2009
 * 
 * Copyright (c) 2009, Mark Betz 
 * 
 * All rights reserved. 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met: 
 * 
 *   * Redistributions of source code must retain the above copyright 
 *     notice, this list of conditions and the following disclaimer. 
 *   * Redistributions in binary form must reproduce the above copyright 
 *     notice, this list of conditions and the following disclaimer in the 
 *     documentation and/or other materials provided with the distribution. 
 *   * Neither the name of the Author nor the names of contributors may be 
 *     used to endorse or promote products derived from this software
 *     without specific prior written permission. 
 *     
 * THIS SOFTWARE IS PROVIDED BY MARK BETZ ''AS IS'' AND ANY  EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL MARK BETZ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 * 
 */
using System.Runtime.Serialization;

namespace GSearch
{
    /// <summary>
    /// Implements the Google phoneNumber json object. This is used
    /// in an embedded array of phone numbers for local search results.
    /// </summary>
    [DataContract(Name="phoneNumber")]
    public class GPhoneNumber
    {
        /// <summary>
        /// A System.String containing a description of the type of
        /// telephone number, i.e. 'mobile' or 'work'.
        /// </summary>
        [DataMember(Name="type")]
        public string Type { get; set; }

        /// <summary>
        /// A System.String containing the telephone number
        /// </summary>
        [DataMember(Name = "number")]
        public string Number { get; set; }
    }
    
    /// <summary>
    /// Implements the local-specific portion of the Google results json object
    /// </summary>
    [DataContract]
    public class GLocalResults : GResults
    {
        /// <summary>
        /// A System.String containing the title or caption of the local search
        /// result. May contain HTML formatting.
        /// </summary>
        [DataMember(Name = "title")]
        public string Title { get; set; }

        /// <summary>
        /// A System.String containing the title or caption of the local search
        /// result, without any HTML formatting.
        /// </summary>
        [DataMember(Name = "titleNoFormatting")]
        public string TitleNoFormatting { get; set; }

        /// <summary>
        /// A System.String containing the URL address of Google's local entry
        /// summary page for this result.
        /// </summary>
        [DataMember(Name = "url")]
        public string Url { get; set; }
        
        /// <summary>
        /// A System.Double containing the Latitude of the local search
        /// result business or location, in decimal degrees.
        /// </summary>
        [DataMember(Name="lat")]
        public double Lat { get; set; }

        /// <summary>
        /// A System.Double containing the Longitude of the local search
        /// result business or location, in decimal degrees.
        /// </summary>
        [DataMember(Name = "lng")]
        public double Lng { get; set; }
        
        /// <summary>
        /// A System.String containing the street address associated with the
        /// local search result.
        /// </summary>
        [DataMember(Name="streetAddress")]
        public string StreetAddress { get; set; }

        /// <summary>
        /// A System.String containing the city where the local search
        /// result is located.
        /// </summary>
        [DataMember(Name = "city")]
        public string City { get; set; }

        /// <summary>
        /// A System.String containing the region in which the local search
        /// result is located. For example, this is usually the state in
        /// US local searches.
        /// </summary>
        [DataMember(Name = "region")]
        public string Region { get; set; }

        /// <summary>
        /// A System.String containing the country where the local search
        /// result is located.
        /// </summary>
        [DataMember(Name = "country")]
        public string Country { get; set; }
        
        /// <summary>
        /// Returns an array of <see cref="GSearch.GPhoneNumber"/> objects
        /// containing the phone numbers associated with this local
        /// search result.
        /// </summary>
        [DataMember(Name="phoneNumbers")]
        public GPhoneNumber[] PhoneNumbers { get; set; }
        
        /// <summary>
        /// A System.String containing a URL address related to mapping and
        /// directions. See the Google API documentation for more information
        /// on these topics.
        /// </summary>
        [DataMember(Name="ddUrl")]
        public string DdUrl { get; set; }

        /// <summary>
        /// A System.String containing a URL address related to mapping and
        /// directions. See the Google API documentation for more information
        /// on these topics.
        /// </summary>
        [DataMember(Name = "ddUrlToHere")]
        public string DdUrlToHere { get; set; }

        /// <summary>
        /// A System.String containing a URL address related to mapping and
        /// directions. See the Google API documentation for more information
        /// on these topics.
        /// </summary>
        [DataMember(Name = "ddUrlFromHere")]
        public string DdUrlFromHere { get; set; }
        
        /// <summary>
        /// A System.String containing the URL address of a thumbnail image
        /// of the map location of the local search result.
        /// </summary>
        [DataMember(Name="staticMapUrl")]
        public string StaticMapUrl { get; set; }
        
        /// <summary>
        /// A System.String containing the type of listings generated by the
        /// search. Set to Local, Kml, or Blended.
        /// <seealso cref="GSearch.SearchLocalResults"/>
        /// </summary>
        [DataMember(Name="listingType")]
        public string ListingType { get; set; }

        /// <summary>
        /// A System.String containing an HTML-formatted snippet of content
        /// associated with the local search result.
        /// </summary>
        [DataMember(Name = "content")]
        public string Content { get; set; }
    }

    /// <summary>
    /// Implements the local-specific portion of the Google responseData
    /// json object
    /// </summary>
    [DataContract]
    public class GLocalResponseData : GResponseData
    {
        /// <summary>
        /// Returns an array of <see cref="GSearch.GLocalResults"/> objects
        /// containing the results of a local search.
        /// </summary>
        [DataMember(Name = "results")]
        public GLocalResults[] Results { get; set; }
    }

    /// <summary>
    /// Implements the local-specific version of the Google response json
    /// object
    /// </summary>
    [DataContract]
    public class GLocalResponse : GResponse
    {
        /// <summary>
        /// An instance of <see cref="GSearch.GLocalResponseData"/> containing
        /// the results of the local search.
        /// </summary>
        [DataMember(Name = "responseData")]
        public GLocalResponseData Response { get; set; }

    }
}